/* Copyright (c) 2004-2024 Peigen.info. All rights reserved. */

package info.peigen.hotpot.business.customer.core.repository.mapper;

import info.peigen.hotpot.business.customer.core.repository.entity.CustomerTechEntity;
import info.peigen.hotpot.component.data.repository.beetlsql.mapper.AbstractBeetlSqlMapper;
import org.apache.ibatis.annotations.Mapper;
import org.beetl.sql.mapper.annotation.Select;
import org.beetl.sql.mapper.annotation.Sql;
import org.beetl.sql.mapper.annotation.Template;
import org.beetl.sql.mapper.annotation.Update;

import java.util.List;

/**
 * <b>(CustomerTechMapper)</b>
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2021/11/3
 */

@SuppressWarnings("AlibabaAbstractMethodOrInterfaceMethodMustUseJavadoc")
@Mapper
public interface CustomerTechMapper extends AbstractBeetlSqlMapper<CustomerTechEntity> {
    @Sql("select * from customer_tech where customer_id = ?")
    @Select
    CustomerTechEntity findByCustomerId(String customerId);

    @Sql("select * from customer_tech where wx_miniapp_user ->'$.openid'  = ?")
    @Select
    CustomerTechEntity findByOpenId(String openId);

    @Template("select * from customer_tech where customer_id in ( #{join(customerIds)} )")
    @Select
    List<CustomerTechEntity> listByCustomerIds(List<String> customerIds);

    @Sql("delete from customer_tech where customer_id = ?")
    @Update
    void deleteByCustomerId(String customerId);

    @Sql("delete from customer_tech where wx_miniapp_user ->'$.openid'  = ?")
    @Update
    void deleteByOpenId(String openId);

}